#include <stdlib.h>
#include "linked_list.h"

/* 	Add a new node to the linked list with the specified data.
	The new node should be added to the front of the list.
*/
void add_node(char *data){
	int i=0;
	NODE* node;
	if (HEAD == NULL){
		/* We are creating the very first node
		   Allocate memory to HEAD here and check for any errors 
		*/
		while(data[i] != "\0"){
			HEAD = (NODE*)malloc(sizeof(NODE));
			HEAD->data = data;
		}
	}
	else{
		/*  Allocate memory for a node here and check for any errors 
		    Make sure you rearange the HEAD to point to this node.
		*/
		while(data[i] != "\s"){
			node = (NODE*)malloc(sizeof(NODE));
			node->data = data;
		}
	}
	printf("Allocated node for %s\n", data);
}
/*
int search(int data){

	NODE* node = HEAD;
	while(node != NULL){
		/* Search through the list and look for the node with the specified data 
		   If found, return 0.
		
	}
	printf("Did not find %d\n", data);
	return -1;
}
*/
/*	Delete a node having the specified data */
/*
int delete_node(int data){

	NODE* node = NULL; 
	NODE* tmp = NULL;

	// If there are no nodes at all, return 0 
	if (HEAD == NULL){
		printf("HEAD is NULL\n");
		return 0;
	}
	// If the HEAD has data delete it and return 0 
	if (HEAD->data == data){
		
	}
	// Search through the list 
	node = HEAD;
	tmp = HEAD->next;
	while(tmp != NULL){
		if (tmp->data == data){
			// Appropriately handle the "next" pointer and delete the data 		
		}
		node = tmp;
		tmp = tmp->next;
	}
	printf("Could not find %d\n", data);
	return -1;	
}
*/

